let  fs  = require("fs");//file  system


fs.readFile("./src/main.js",{encoding:"utf-8"},(err,data)=>{
    // console.log(data);
    let fileName = "main"+Date.now()+".js"
    fs.writeFile("./dist/"+fileName,data,()=>{
        fs.readFile("./public/index.html",{encoding:"utf-8"},(err,html)=>{
            // console.log(data);
            let newHTML  = html.replace("</body>",`</body><script src='./${fileName}'></script>`)
            fs.writeFile("./dist/index.html",newHTML,()=>{
               
            })
        })
   
    })
})

